package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BCareRecordService;
import top.tangyh.lamp.care.entity.BCareRecord;
import top.tangyh.lamp.care.vo.query.CareItemQueryParam;
import top.tangyh.lamp.care.vo.query.CareRecordQueryDto;
import top.tangyh.lamp.care.vo.query.CareRecordQueryParam;
import top.tangyh.lamp.care.vo.result.CareItemVO;
import top.tangyh.lamp.care.vo.result.CareRecordQuery2AxiosDto;
import top.tangyh.lamp.care.vo.save.BCareRecordSaveVO;
import top.tangyh.lamp.care.vo.update.BCareRecordUpdateVO;
import top.tangyh.lamp.care.vo.result.BCareRecordResultVO;
import top.tangyh.lamp.care.vo.query.BCareRecordPageQuery;
import top.tangyh.lamp.care.vo.update.CareRecordDelInVO;
import top.tangyh.lamp.care.vo.update.UpdateCareRecordStatusVO;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * 护理操作记录表
 * </p>
 *
 * @author zqb
 * @date 2024-07-18 14:10:32
 * @create [2024-07-18 14:10:32] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/careRd")
@Tag(name = "护理操作记录")
public class BCareRecordController {
//    extends SuperController<BCareRecordService, Long, BCareRecord
//            , BCareRecordSaveVO, BCareRecordUpdateVO, BCareRecordPageQuery, BCareRecordResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private final BCareRecordService bCareRecordService;


    @PostMapping("/queryBy2Axios")
    @Operation(summary = "查询护理操作记录，返回表结构数据(护理记录模块需要调用)")
    public R<CareRecordQuery2AxiosDto> listBy2Axios(@Valid @RequestBody CareRecordQueryParam yxCareRecordQueryParam) {
        return R.success(bCareRecordService.queryBy2Axios(yxCareRecordQueryParam));
    }

    @PostMapping("/query")
    @Operation(summary = "查询护理操作记录")
    public R<List<CareRecordQueryDto>> list(@Valid @RequestBody CareRecordQueryParam yxCareRecordQueryParam) {
        return R.success(bCareRecordService.query(yxCareRecordQueryParam));
    }

    @GetMapping("/item/query")
    @Operation(summary = "查询病人护理操选项")
    public R<List<CareItemVO>> list(CareItemQueryParam careItemQueryParam) {
        return R.success(bCareRecordService.itemQuery(careItemQueryParam));
    }

    @Operation(summary = "保存护理操作记录")
    @PostMapping("/save")
    public R<Integer> save(@Valid @RequestBody List<CareRecordQueryDto> param) throws Exception {
        return R.success(bCareRecordService.addAndUpdate(param));
    }

    @PutMapping
    @Operation(summary = "删除指定记录点数据")
    public R<Integer> delcell(@Valid @RequestBody CareRecordDelInVO param) {
        return R.success(bCareRecordService.delCell(param));
    }

    @PutMapping("/status")
    @Operation(summary = "更改该病人该时间点所有护理操作的状态")
    public R updateRecordStatus(@RequestBody @Valid UpdateCareRecordStatusVO updateStatusVO) {
        bCareRecordService.updateRecordStatus(updateStatusVO);
        return R.success();
    }


}


